// components/footer/footer.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    cur:{
      type: String,
      observer: function (value) {
        this.hidetabbar()
        // this.setData({
        //   curIndex: value
        // })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    curIndex: '0',
    isiphonex: getApp().globalData.isiphonex,
    fontList:[
      {}
    ],
    isX: false,
    tabBar: {
      color: "#d7dce5",
      selectedColor: "#21de81",
      list: [{
           pagePath: "/pages/index/index",
           text: "首页",
           iconPath: "/static/icon/home.png",
           selectedIconPath: "/static/icon/home_active.png"
         },
         {
           pagePath: "/pages/course/course",
           text: "课程",
           iconPath: "/static/icon/course.png",
           selectedIconPath: "/static/icon/course_active.png"
         },
          {
            pagePath: "/pages/sign/sign",
            text: "报名",
            iconPath: "/static/icon/sign.png",
            selectedIconPath: "/static/icon/sign_active.png"
         },
           {
             pagePath: "/pages/coupons/coupons",
             text: "优惠",
             iconPath: "/static/icon/coupons.png",
             selectedIconPath: "/static/icon/coupons_active.png"
        }, {
          pagePath: "/pages/me/me",
          text: "我的",
          iconPath: "/static/icon/me.png",
          selectedIconPath: "/static/icon/me_active.png"
        }
      
      
      ]
        
     }
  },
  attached() {
    // 第二种方式通过组件的生命周期函数执行代码
      let isX=this.data.isX
      let info = wx.getSystemInfoSync();
      if (/iPhone X/i.test(info.model)) {
        isX = true
        // return true;
      } else {
        isX=false
        // return false;
      }
      console.log(isX);
      
      this.setData({
        isX
      })
  },
  /**
   * 组件的方法列表
   */
  methods: {
     hidetabbar() {
       wx.hideTabBar({
         fail: function () {
           setTimeout(function () { // 做了个延时重试一次，作为保底。
             wx.hideTabBar()
           }, 500)
         }
       });
     },
    go(e){
      let url = e.currentTarget.dataset.url
      console.log(121212);
      // wx.redirectTo({
      //   url
      // });
        
     wx.switchTab({
        url
      });
    // if (wx.getStorageSync('user').userid) {
    //    wx.switchTab({
    //      url
    //    });
    // } else {
    //    wx.navigateTo({
    //      url:"/pages/login/login",
    //    });
    // }
       
       
     
    },
  }
})
